package com.lin.mapper;

import com.github.pagehelper.Page;
import com.lin.entity.MusicCategory;
import com.lin.entity.Search;
import com.lin.entity.dto.MusicDTO;
import com.lin.entity.vo.MusicVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MusicMapper {


    @Select("select * from music_category")
    List<MusicCategory> getCategory();

    List<MusicVO> getRecommend();

    /**
     * 按条件分页查询
     *
     * @return
     */
    Page<MusicVO> getMusic(MusicDTO musicDTO);

    @Insert("insert into search(text,user_id,time) values (#{text},#{userId},#{time})")
    void setSearch(Search search);

    /**
     * 获取用户的搜索历史
     * @param userId
     * @return
     */
    @Select("select * from search where user_id = #{userId}")
    List<Search> getSearchByUserId(Integer userId);

    List<String> getPopularSearches();

    void deleteSearch(Search search);

    @Select("select * from music where id = #{id}")
    MusicVO getMusicDetail(Integer id);

    void updateMusic(MusicVO musicVO);
}
